class Solution:
    def compareVersion(self, version1: str, version2: str) -> int:
        version1Sp=version1.split(".")
        version2Sp=version2.split(".")
        r=len(version1Sp)
        for i in reversed(range(0,len(version1Sp))):
            version1Sp[i]=str(int(version1Sp[i]))

            if version1Sp[i]=='0' and r ==i+1:
                r=i
        version1Sp=version1Sp[0:r]
        r=len(version2Sp)
        for i in reversed(range(0,len(version2Sp))):
            version2Sp[i]=str(int(version2Sp[i]))
            if version2Sp[i] =='0' and r==i+1:
                r=i
        
        version2Sp=version2Sp[0:r]
        minLen=len(version1Sp)
        ans=-1
        if minLen>len(version2Sp):
            minLen=len(version2Sp)
            ans=1
        elif minLen==len(version2Sp):
            ans=0
        for i in range(0,minLen):
            if int(version1Sp[i])>int(version2Sp[i]):
                return 1
            elif int(version1Sp[i])<int(version2Sp[i]):
                return-1
        return ans